package com.jy.modules.cims.data.dto;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.jy.modules.cims.common.CimsConstant;
import com.jy.modules.cims.common.sysUtils.SimpleBeanUtils;
import com.jy.modules.cims.data.common.dto.TCMmCreditDealDetailDTO;
import com.jy.modules.cims.data.common.dto.TCMmCreditDetailDTO;
import com.jy.modules.cims.data.common.dto.TCMmQuotaCreditDetailDTO;
import com.jy.modules.cims.data.interact.core.credit.response.Response4050ResultDTO;

/**
 * 二次购买（接口对象转换实体）
 * @author zhangmi
 * @date
 */
public class CreditDetailSecondDto {

	/**债权转让编号*/
	private String transferId;
	/**交割日期*/
	private Date deliveryDate;
	/**交割日价值*/
	private BigDecimal deliveryCreditValue;
	/**确认日期*/
	private Date bizDate;
	/**确认日债权价值*/
	private BigDecimal creditTodayValue;
	/**月还*/
	private BigDecimal eachRepaymentValue;
	/**结清日期*/
	private Date settleCreditDate;
	/**结清价值*/
	private BigDecimal settleCreditValue;
	/**债权状态 10:已转让在途 11:已确认转让 12:已赎回 90:债权账单日变更 95:提前结清 97:正常结清 89:展期结清 88:债务重组 */
	private String state;
	/**机构编号*/
	private String cCode;
	/**额度申请编号*/
    private String applyId;
    /**债权协议编号*/
    private String creditId;
    /**合同编号*/
    private String contranctNo;
    /** 合同金额 */
    private BigDecimal contractValue;
    /** 放款金额 */
    private BigDecimal loanValue;
    /** 贷款人客户编号 */
    private java.lang.String loanUserId;
    /** 借款用途 */
    private java.lang.String loanUse;
    /** 初始放款日期 */
    private java.util.Date initialDate;
    /** 还款起始日期 */
    private java.util.Date startRepaymentDate;
    /** 账单日 */
    private java.lang.Long billDate;
    /** 还款期数（月） */
    private java.lang.Long repaymentMonth;
    /** 剩余还款期数 */
    private Long surplusRepaymentMonth;
    /** 贷款产品代码 */
    private java.lang.String loanProductCode;
    /** 贷款产品名称 */
    private java.lang.String loanProductName;
    /** 贷款产品月利率 */
    private BigDecimal loanMonthlyInterest;
    /** 还款方式 */
    private java.lang.String repaymentType;
    
    private java.lang.String loanType;

    
    
    /**
     * 债权明细
     * @author zhangmi
     * @date  2017年2月27日
     * @param creditDto
     * @param tcmmCreditDto
     */
    public static void ToCreditDetailDto(CreditDetailSecondDto creditDto,TCMmCreditDetailDTO tcmmCreditDto){
    	
    	creditDto.getApplyId();
    	tcmmCreditDto.setBillDate(creditDto.getBillDate());
    	tcmmCreditDto.setBizDate(creditDto.getBizDate()); //当前会计日
    	tcmmCreditDto.setCooperorgCode(creditDto.getcCode());
    	tcmmCreditDto.setContractSum(creditDto.getContractValue());
    	tcmmCreditDto.setCreditCode(creditDto.getCreditId()); //合同号对应：债权编号
    	creditDto.getCreditId();  //协议号
    	creditDto.getCreditTodayValue();
    	
    	tcmmCreditDto.setMakeCreditorValue(creditDto.getDeliveryCreditValue());
    	tcmmCreditDto.setDeliverDate(creditDto.getDeliveryDate());
    	tcmmCreditDto.setThisRepaySum(creditDto.getEachRepaymentValue());
    	tcmmCreditDto.setInitialLoanDate(creditDto.getInitialDate());
    	tcmmCreditDto.setMonthlyRate(creditDto.getLoanMonthlyInterest());

    	
    	tcmmCreditDto.setBizDate(creditDto.getSettleCreditDate());
    	tcmmCreditDto.setLoanMonthlyinterest(creditDto.getLoanMonthlyInterest());
    	tcmmCreditDto.setLoanSum(creditDto.getLoanValue());
    	tcmmCreditDto.setThisCreditorValue(creditDto.getCreditTodayValue());
    	tcmmCreditDto.setLoanProductCode(creditDto.getLoanProductCode());
    	tcmmCreditDto.setLoanProductName(creditDto.getLoanProductName());
    	tcmmCreditDto.setThisMakeCreditorValue(creditDto.getDeliveryCreditValue());
    	
    	//01信用贷，02车贷，03房贷
    	if(CimsConstant.CORE_PRODUCT_TYPE_CREDIT.equals(creditDto.getLoanType())){
    		tcmmCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CREDIT);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_HOUSE.equals(creditDto.getLoanType())){
    		tcmmCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_HOUSE);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_CAR_YJ.equals(creditDto.getLoanType())){
    		tcmmCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CAR);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_CAR_GPS.equals(creditDto.getLoanType())){
    		tcmmCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CAR);
    	}else{
    		tcmmCreditDto.setProductType("");
    	}
    		
    	//creditDto.getLoanUse(); //借款用途
    	tcmmCreditDto.setBorrowerUse(creditDto.getLoanUse());
    	tcmmCreditDto.setLoanUserId(creditDto.getLoanUserId());
    	tcmmCreditDto.setRepayPeriod(creditDto.getRepaymentMonth());
    	tcmmCreditDto.setRepayType(creditDto.getRepaymentType());
    	
    	creditDto.getSettleCreditDate();
    	creditDto.getSettleCreditValue();

    	tcmmCreditDto.setLoanUserId(creditDto.getLoanUserId());
    	tcmmCreditDto.setLoanProductCode(creditDto.getLoanProductCode());
    	tcmmCreditDto.setLoanProductCode(creditDto.getLoanProductName());
    	tcmmCreditDto.setRepayStartDate(creditDto.getStartRepaymentDate());
    	tcmmCreditDto.setCoreCreditStatus(creditDto.getState());
    	tcmmCreditDto.setResidueRepayPeriod(creditDto.getSurplusRepaymentMonth());
    	tcmmCreditDto.setTransferId(creditDto.getTransferId());
    	
    } 
    
    
    /**
     * 债权交易明细
     * @author zhangmi
     * @date  2017年2月27日
     * @param creditDto
     * @param tcmmCreditDto
     */
    public static void ToCreditDealDetailDto(CreditDetailSecondDto creditDto,TCMmCreditDealDetailDTO tcmmCreditDto){
    	creditDto.getApplyId();
    	tcmmCreditDto.setBillDate(creditDto.getBillDate());
//    	tcmmCreditDto.setBizDate(creditDto.getBizDate()); //当前会计日
    	tcmmCreditDto.setCooperorgCode(creditDto.getcCode());
//    	tcmmCreditDto.setContractSum(creditDto.getContractValue());
//    	tcmmCreditDto.setCreditCode(creditDto.getContranctNo()); //合同号对应：债权编号
    	creditDto.getCreditId();  //协议号
    	creditDto.getCreditTodayValue();

    	tcmmCreditDto.setThisMakeCreditorValue(creditDto.getDeliveryCreditValue());
    	tcmmCreditDto.setThisCreditorValue(creditDto.getCreditTodayValue());
    	tcmmCreditDto.setRepayPeriod(creditDto.getRepaymentMonth());
    	tcmmCreditDto.setMakeCreditorValue(creditDto.getDeliveryCreditValue());
    	tcmmCreditDto.setDeliverDate(creditDto.getDeliveryDate());
    	tcmmCreditDto.setThisRepaySum(creditDto.getEachRepaymentValue());
//    	tcmmCreditDto.setInitialLoanDate(creditDto.getInitialDate());
//    	tcmmCreditDto.setMonthlyRate(creditDto.getLoanMonthlyInterest());
//    	
//    	tcmmCreditDto.setLoanSum(creditDto.getLoanValue());
//    	
//    	tcmmCreditDto.setLoanProductCode(creditDto.getLoanProductCode());
//    	tcmmCreditDto.setLoanProductName(creditDto.getLoanProductName());
    	
    	//01信用贷，02车贷，03房贷
    	if(CimsConstant.CORE_PRODUCT_TYPE_CREDIT.equals(creditDto.getLoanType())){
    		tcmmCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CREDIT);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_HOUSE.equals(creditDto.getLoanType())){
    		tcmmCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_HOUSE);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_CAR_YJ.equals(creditDto.getLoanType())){
    		tcmmCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CAR);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_CAR_GPS.equals(creditDto.getLoanType())){
    		tcmmCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CAR);
    	}else{
    		tcmmCreditDto.setProductType("");
    	}
    	
    	//creditDto.getLoanUse(); //借款用途
//    	tcmmCreditDto.setLoanUserId(creditDto.getLoanUserId());
    	tcmmCreditDto.setRepayPeriod(creditDto.getRepaymentMonth());
//    	tcmmCreditDto.setRepayType(creditDto.getRepaymentType());
    	
    	creditDto.getSettleCreditDate();
    	creditDto.getSettleCreditValue();
    	
    	
//    	tcmmCreditDto.setRepayStartDate(creditDto.getStartRepaymentDate());
    	tcmmCreditDto.setCoreCreditStatus(creditDto.getState());
    	tcmmCreditDto.setResidueRepayPeriod(creditDto.getSurplusRepaymentMonth());
    	tcmmCreditDto.setTransferId(creditDto.getTransferId());
    	tcmmCreditDto.setCreditorId(creditDto.getCreditId());
    } 
    
    

    /**
     * 额度明细
     * @author zhangmi
     * @date  2017年2月27日
     * @param creditDto
     * @param tcmmQuotaCreditDto
     */
    public static void ToQuotaCreditDetailDto(CreditDetailSecondDto creditDto,TCMmQuotaCreditDetailDTO tcmmQuotaCreditDto){
    	
    	tcmmQuotaCreditDto.setQuotaCode(creditDto.getApplyId());
    	tcmmQuotaCreditDto.setBillDate(creditDto.getBillDate());
//    	tcmmQuotaCreditDto.setBizDate(creditDto.getBizDate()); //当前会计日
    	tcmmQuotaCreditDto.setCooperorgCode(creditDto.getcCode());
    	tcmmQuotaCreditDto.setContractSum(creditDto.getContractValue());
    	tcmmQuotaCreditDto.setCreditCode(creditDto.getCreditId()); //合同号对应：债权编号
    	creditDto.getCreditId();  //协议号
    	creditDto.getCreditTodayValue();
    	
    	tcmmQuotaCreditDto.setThisMakeCreditorValue(creditDto.getDeliveryCreditValue());//本次转让债权价值：交割日债权价值
//    	tcmmQuotaCreditDto.setDeliverDate(creditDto.getDeliveryDate());

    	tcmmQuotaCreditDto.setThisCreditorValue(creditDto.getCreditTodayValue());
    	
    	tcmmQuotaCreditDto.setThisRepaySum(creditDto.getEachRepaymentValue());
    	tcmmQuotaCreditDto.setInitialLoanDate(creditDto.getInitialDate());
    	tcmmQuotaCreditDto.setMonthlyRate(creditDto.getLoanMonthlyInterest());
    	tcmmQuotaCreditDto.setLoanMonthlyinterest(creditDto.getLoanMonthlyInterest());
    	
    	tcmmQuotaCreditDto.setLoanSum(creditDto.getLoanValue());
    	
    	tcmmQuotaCreditDto.setLoanProductCode(creditDto.getLoanProductCode());
    	tcmmQuotaCreditDto.setLoanProductName(creditDto.getLoanProductName());
    	
    	//01信用贷，02车贷，03房贷
    	if(CimsConstant.CORE_PRODUCT_TYPE_CREDIT.equals(creditDto.getLoanType())){
    		tcmmQuotaCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CREDIT);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_HOUSE.equals(creditDto.getLoanType())){
    		tcmmQuotaCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_HOUSE);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_CAR_YJ.equals(creditDto.getLoanType())){
    		tcmmQuotaCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CAR);
    	}else if(CimsConstant.CORE_PRODUCT_TYPE_CAR_GPS.equals(creditDto.getLoanType())){
    		tcmmQuotaCreditDto.setProductType(CimsConstant.PRODUCT_TYPE_CAR);
    	}else{
    		tcmmQuotaCreditDto.setProductType("");
    	}
    		
    	//creditDto.getLoanUse(); //借款用途
    	tcmmQuotaCreditDto.setBorrowerUse(creditDto.getLoanUse());
    	tcmmQuotaCreditDto.setLoanUserId(creditDto.getLoanUserId());
    	tcmmQuotaCreditDto.setRepayPeriod(creditDto.getRepaymentMonth());
    	tcmmQuotaCreditDto.setRepayType(creditDto.getRepaymentType());
    	
//    	creditDto.getSettleCreditDate();
//    	creditDto.getSettleCreditValue();
    	
    	
    	tcmmQuotaCreditDto.setRepayStartDate(creditDto.getStartRepaymentDate());
    	tcmmQuotaCreditDto.setCoreCreditStatus(creditDto.getState());
    	tcmmQuotaCreditDto.setResidueRepayPeriod(creditDto.getSurplusRepaymentMonth());
    	tcmmQuotaCreditDto.setTransferId(creditDto.getTransferId());
    	
    } 
    /**
     * Response4050ResultDTO复制CreditDetailSecondDto
     * @author zhangmi
     * @date  2017年2月27日
     * @param list
     * @return
     * @throws Exception
     */
    public static List<CreditDetailSecondDto> ToListCreditDetailSecondDto(List<Response4050ResultDTO> list) throws Exception{
    	 List<CreditDetailSecondDto> resultList =new ArrayList<CreditDetailSecondDto>();
    	 CreditDetailSecondDto resultDto = null;
    	 for (Response4050ResultDTO response4050ResultDTO : list) {
    		resultDto = new CreditDetailSecondDto();
    		SimpleBeanUtils.copyBean2Bean(resultDto, response4050ResultDTO);
    		resultList.add(resultDto);
    	 }
    	 return resultList;
    }
    
    
    
    
    
    
	public String getTransferId() {
		return transferId;
	}

	public void setTransferId(String transferId) {
		this.transferId = transferId;
	}

	public Date getDeliveryDate() {
		return deliveryDate;
	}

	public void setDeliveryDate(Date deliveryDate) {
		this.deliveryDate = deliveryDate;
	}

	public BigDecimal getDeliveryCreditValue() {
		return deliveryCreditValue;
	}

	public void setDeliveryCreditValue(BigDecimal deliveryCreditValue) {
		this.deliveryCreditValue = deliveryCreditValue;
	}

	public Date getBizDate() {
		return bizDate;
	}

	public void setBizDate(Date bizDate) {
		this.bizDate = bizDate;
	}

	public BigDecimal getCreditTodayValue() {
		return creditTodayValue;
	}

	public void setCreditTodayValue(BigDecimal creditTodayValue) {
		this.creditTodayValue = creditTodayValue;
	}

	public BigDecimal getEachRepaymentValue() {
		return eachRepaymentValue;
	}

	public void setEachRepaymentValue(BigDecimal eachRepaymentValue) {
		this.eachRepaymentValue = eachRepaymentValue;
	}

	public Date getSettleCreditDate() {
		return settleCreditDate;
	}

	public void setSettleCreditDate(Date settleCreditDate) {
		this.settleCreditDate = settleCreditDate;
	}

	public BigDecimal getSettleCreditValue() {
		return settleCreditValue;
	}

	public void setSettleCreditValue(BigDecimal settleCreditValue) {
		this.settleCreditValue = settleCreditValue;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getcCode() {
		return cCode;
	}

	public void setcCode(String cCode) {
		this.cCode = cCode;
	}

	public String getApplyId() {
		return applyId;
	}

	public void setApplyId(String applyId) {
		this.applyId = applyId;
	}

	public String getCreditId() {
		return creditId;
	}

	public void setCreditId(String creditId) {
		this.creditId = creditId;
	}

	public String getContranctNo() {
		return contranctNo;
	}

	public void setContranctNo(String contranctNo) {
		this.contranctNo = contranctNo;
	}

	public BigDecimal getContractValue() {
		return contractValue;
	}

	public void setContractValue(BigDecimal contractValue) {
		this.contractValue = contractValue;
	}

	public BigDecimal getLoanValue() {
		return loanValue;
	}

	public void setLoanValue(BigDecimal loanValue) {
		this.loanValue = loanValue;
	}

	public java.lang.String getLoanUserId() {
		return loanUserId;
	}

	public void setLoanUserId(java.lang.String loanUserId) {
		this.loanUserId = loanUserId;
	}

	public java.lang.String getLoanUse() {
		return loanUse;
	}

	public void setLoanUse(java.lang.String loanUse) {
		this.loanUse = loanUse;
	}

	public java.util.Date getInitialDate() {
		return initialDate;
	}

	public void setInitialDate(java.util.Date initialDate) {
		this.initialDate = initialDate;
	}

	public java.util.Date getStartRepaymentDate() {
		return startRepaymentDate;
	}

	public void setStartRepaymentDate(java.util.Date startRepaymentDate) {
		this.startRepaymentDate = startRepaymentDate;
	}

	public java.lang.Long getBillDate() {
		return billDate;
	}

	public void setBillDate(java.lang.Long billDate) {
		this.billDate = billDate;
	}

	public java.lang.Long getRepaymentMonth() {
		return repaymentMonth;
	}

	public void setRepaymentMonth(java.lang.Long repaymentMonth) {
		this.repaymentMonth = repaymentMonth;
	}

	public Long getSurplusRepaymentMonth() {
		return surplusRepaymentMonth;
	}

	public void setSurplusRepaymentMonth(Long surplusRepaymentMonth) {
		this.surplusRepaymentMonth = surplusRepaymentMonth;
	}

	public java.lang.String getLoanProductCode() {
		return loanProductCode;
	}

	public void setLoanProductCode(java.lang.String loanProductCode) {
		this.loanProductCode = loanProductCode;
	}

	public java.lang.String getLoanProductName() {
		return loanProductName;
	}

	public void setLoanProductName(java.lang.String loanProductName) {
		this.loanProductName = loanProductName;
	}

	public BigDecimal getLoanMonthlyInterest() {
		return loanMonthlyInterest;
	}

	public void setLoanMonthlyInterest(BigDecimal loanMonthlyInterest) {
		this.loanMonthlyInterest = loanMonthlyInterest;
	}

	public java.lang.String getRepaymentType() {
		return repaymentType;
	}

	public void setRepaymentType(java.lang.String repaymentType) {
		this.repaymentType = repaymentType;
	}

	public java.lang.String getLoanType() {
		return loanType;
	}

	public void setLoanType(java.lang.String loanType) {
		this.loanType = loanType;
	}
    
}
